-import sys
import asyncio
import logging
-import time
from .client import Client
from .client import InsertError
from .client import PoolError
from .series import Series
from .pipe_client import PipeClient as SiriDBAsyncUnixConnection
from .args import parse_args
-
-SPINNER1 = \
- ('▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▇', '▆', '▅', '▄', '▃', '▁')
-SPINNER2 = \
- ('⠁', '⠂', '⠄', '⡀', '⢀', '⠠', '⠐', '⠈')
-SPINNER3 = \
- ('◐', '◓', '◑', '◒')
-
-
-class Spinner():
-
- def __init__(self, charset=SPINNER3):
- self._idx = 0
- self._charset = charset
- self._len = len(charset)
-
- @property
- def next(self):
- char = self._charset[self._idx]
- self._idx += 1
- self._idx %= self._len
- return char
-
-
-class Task():
- def __init__(self, title):
- self.running = True
- self.task = asyncio.ensure_future(self.process())
- self.success = False
- self.title = title
- self.start = time.time()
-
- def stop(self, success):
- self.running = False
- self.success = success
- self.duration = time.time() - self.start
-
- async def process(self):
- spinner = Spinner()
- while self.running:
- sys.stdout.write(f'{self.title:.<76}{spinner.next}\r')
- sys.stdout.flush()
- await asyncio.sleep(0.2)
-
- if self.success:
- print(f'{self.title:.<76}OK ({self.duration:.2f} seconds)')
- else:
- print(f'{self.title:.<76}FAILED ({self.duration:.2f} seconds)')
+from .task import Task
async def _run_test(test, loglevel):
+import os
+import subprocess
import argparse
from .server import Server
+from .color import Color
+
+
+def is_valgrind_installed():
+ with open(os.devnull, 'w') as fnull:
+ try:
+ subprocess.call(['valgrind'], stdout=fnull, stderr=fnull)
+ except OSError as e:
+ if e.errno == os.errno.ENOENT:
+ return False
+ return True
def parse_args():
args = parser.parse_args()
- Server.MEM_CHECK = args.mem_check
+ has_valgrind = is_valgrind_installed()
+
+ print("Test using valgrind for memory errors and leaks: ", end='')
+ if args.mem_check and not has_valgrind:
+ print(Color.warning('disabled (!! valgrind not found !!)'))
+ elif not args.mem_check:
+ print(Color.warning('disabled'))
+ else:
+ print(Color.success('enabled'))
+
+ Server.MEM_CHECK = args.mem_check and has_valgrind
Server.HOLD_TERM = args.keep
Server.TERMINAL = args.terminal
Server.BUILDTYPE = args.build
--- /dev/null
+
+NORMAL = '\x1B[0m'
+RED = '\x1B[31m'
+GREEN = '\x1B[32m'
+YELLOW = '\x1B[33m'
+
+
+class Color:
+
+ @staticmethod
+ def success(text):
+ return f'{GREEN}{text}{NORMAL}'
+
+ @staticmethod
+ def warning(text):
+ return f'{YELLOW}{text}{NORMAL}'
+
+ @staticmethod
+ def error(text):
+ return f'{RED}{text}{NORMAL}'
+
+
--- /dev/null
+SPINNER1 = \
+ ('▁', '▂', '▃', '▄', '▅', '▆', '▇', '█', '▇', '▆', '▅', '▄', '▃', '▁')
+SPINNER2 = \
+ ('⠁', '⠂', '⠄', '⡀', '⢀', '⠠', '⠐', '⠈')
+SPINNER3 = \
+ ('◐', '◓', '◑', '◒')
+
+
+class Spinner():
+
+ def __init__(self, charset=SPINNER3):
+ self._idx = 0
+ self._charset = charset
+ self._len = len(charset)
+
+ @property
+ def next(self):
+ char = self._charset[self._idx]
+ self._idx += 1
+ self._idx %= self._len
+ return char
--- /dev/null
+import sys
+import time
+import asyncio
+from .spinner import Spinner
+from .color import Color
+
+
+class Task():
+ def __init__(self, title):
+ self.running = True
+ self.task = asyncio.ensure_future(self.process())
+ self.success = False
+ self.title = title
+ self.start = time.time()
+
+ def stop(self, success):
+ self.running = False
+ self.success = success
+ self.duration = time.time() - self.start
+
+ async def process(self):
+ spinner = Spinner()
+ while self.running:
+ sys.stdout.write(f'{self.title:.<76}{spinner.next}\r')
+ sys.stdout.flush()
+ await asyncio.sleep(0.2)
+
+ if self.success:
+ print(
+ f'{self.title:.<76}'
+ f'{Color.success("OK")} ({self.duration:.2f} seconds)')
+ else:
+ print(
+ f'{self.title:.<76}'
+ f'{Color.error("FAILED")} ({self.duration:.2f} seconds)')
+
+#include <stdio.h>
+#include <stdlib.h>
#include "../test.h"
#include <siri/version.h>
-#include <stdio.h>
-#include <stdlib.h>
int old_version_cmp(const char * version_a, const char * version_b)
{
a = strtol(str_a, &str_a, 10);
b = strtol(str_b, &str_b, 10);
- printf("%ld - %ld\n", a, b);
-
if (a != b)
{
return a - b;